package com.newgoldcurrency.activities.main;

import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.newgoldcurrency.R;
import com.newgoldcurrency.databinding.FragmentWalletBinding;
import com.newgoldcurrency.utils.Tools;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class WalletFragment extends Fragment {
    private FragmentWalletBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        binding = FragmentWalletBinding.inflate(inflater, container, false);
        Tools.toast("Coming soon");
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("Address:******************************************************************************************************************** Copy");
        Pattern patternRegistration = Pattern.compile("Copy");
        Matcher matcherRegistration = patternRegistration.matcher(spannableStringBuilder);
        while (matcherRegistration.find()) {
            spannableStringBuilder.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.mainColor)), matcherRegistration.start(), matcherRegistration.end(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
            spannableStringBuilder.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), matcherRegistration.start(), matcherRegistration.end(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        }
        binding.walletAddress.setText(spannableStringBuilder);
        return binding.getRoot();
    }
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}